package cn.edu.zafu.bigdata.linfeifei;

public class TestInterface {
    public static void main(String[] args) {
        // 创建 AutoMobile 和 ResizableCircle 的实例
        Movable autoMobile = new AutoMobile();
        Movable resizableCircle = new ResizableCircle(5);

        // 验证 AutoMobile 类对 Movable 接口方法的实现
        System.out.println("AutoMobile movement:");
        autoMobile.move();
        autoMobile.stop();

        // 验证 ResizableCircle 类对 Movable 接口方法的实现
        System.out.println("\nResizableCircle movement:");
        resizableCircle.move();
        resizableCircle.stop();

        // 验证 ResizableCircle 类对 Resizable 接口方法的实现
        System.out.println("\nResizableCircle resizing:");
        ((Resizable)resizableCircle).resize(2.0);
    }

    public static interface Movable {
        void move();
        void stop();
    }

    public static interface Resizable {
        void resize(double factor);
    }

    public static class AutoMobile implements Movable {
        @Override
        public void move() {
            System.out.println("The car is moving.");
        }

        @Override
        public void stop() {
            System.out.println("The car has stopped.");
        }
    }

    public static class ResizableCircle implements Movable, Resizable {
        private double radius;

        public ResizableCircle(double radius) {
            this.radius = radius;
        }

        @Override
        public void move() {
            System.out.println("The circle is moving.");
        }

        @Override
        public void stop() {
            System.out.println("The circle has stopped.");
        }

        @Override
        public void resize(double factor) {
            this.radius *= factor;
            System.out.println("The circle's radius after resizing is: " + this.radius);
        }
    }
}

